package com.oss.intercept.sys;

import cn.hutool.crypto.SecureUtil;
import com.eova.aop.AopContext;
import com.eova.aop.MetaObjectIntercept;
import com.jfinal.plugin.activerecord.Record;

public class SysEmployeeIntercept extends MetaObjectIntercept {

    @Override
    public String addBefore(AopContext ac) throws Exception {
        // 将密码更改为MD5加密
        Record r = ac.record;
        String userPassword = r.getStr("password");
        String passWord = SecureUtil.md5(userPassword);
        r.set("password", passWord);
        return super.addBefore(ac);
    }

    @Override
    public String updateBefore(AopContext ac) throws Exception {
        // 将密码更改为MD5加密
        Record r = ac.record;
        String userPassword = r.getStr("password");
        String passWord = SecureUtil.md5(userPassword);
        r.set("password", passWord);
        return super.updateBefore(ac);
    }

}
